﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ArrowScheduleCore
{
    /// <summary>
    /// Properties specific to a daily schedule. This is set to either run all weekdays or run every Nth day.
    /// </summary>
    public class ScheduleDaily : SchedulePeriod
    {
        /// <summary>
        /// What daily cycle is used.
        /// </summary>
        public enum CYCLE
        {
            /// <summary>
            /// Every weekday (ignore period).
            /// </summary>
            WEEKDAYS,
            /// <summary>
            /// Every nth day.
            /// </summary>
            PERIOD
        };

        private CYCLE cycle;	// DB: runCycle
        private int period;		// DB: runPeriod

        /// <summary>
        /// Create an object.
        /// </summary>
        /// <param name="cycle">How this is scheduled daily.</param>
        /// <param name="period">Schedule this every N days. Must be greater than 0.</param>
        public ScheduleDaily(CYCLE cycle, int period)
        {
            this.cycle = cycle;
            this.period = period;
        }

        /// <summary>
        /// How this is scheduled daily.
        /// </summary>
        public CYCLE Cycle
        {
            get { return cycle; }
            set { cycle = value; }
        }

        /// <summary>
        /// If using the PERIOD cycle, schedule every N (period) days. This must be greater than 0.
        /// </summary>
        public int Period
        {
            get { return period; }
            set { period = value; }
        }

        /// <summary>
        /// Use this instead of class type only when necessary such as a switch statement.
        /// </summary>
        public override REPEAT RepeatType
        {
            get { return REPEAT.DAILY; }
        }

        /// <summary>
        /// A human readable description of the period.
        /// </summary>
        public override string Description
        {
            get
            {
                if (cycle == CYCLE.WEEKDAYS)
                    return GlobalStrings.ScheduleDaily_schdDayWeekdays;
                return string.Format(GlobalStrings.ScheduleDaily_schdDayNDays, period);
            }
        }
    }
}
